<style>
.fui-header:after {
	height: 0;
	border-bottom: 0 solid #D9D9D9;
}
.search-input input {
	border-radius: 1rem;
	background-color:#f2f2f2;
	border: 0 solid #ddd;
}
</style>
<div ng-show="pagedata.isshowarea ==1">
<div class="fui-page fui-page-current page-goods-list" style="background:#fff">
	<div class="fui-header" style="background:none">
		<div class="title bold" style="font-size:1rem;">定位城市</div>
		<div class="fui-header-right" style="padding-right:0.5rem;">
			<i class="icon jinyunicon icon-fenxiang2" onclick="$('#showsharecover').modal();" style="font-size: 1rem;margin-right:10px"></i>
			<i class="icon jinyunicon icon-wo1" ng-click="access_json('jy_newpaimerch/myhome/')" style="font-size: 1rem;"></i>
		</div>
	</div>
<div class="fui-content" style="top:1.3rem;background:#fff">
		<div class="fui-cell-group">
			<div class="fui-cell">
				<div class="fui-cell-label" style="width:auto" ng-init="pagedata.getprovince()">
					<span style="font-size:0.75rem">{{pagedata.pcd.city || pagedata.pluginset.city}}</span>
					<i class="icon jinyunicon icon-moreunfold"></i>
				</div>
				<div ng-click="pagedata.choose_location()" class="fui-cell-info search-input">
					<i id="searchsub" class="fa fa-search"  ng-click="pagedata.getmerchs()"></i>
					<input type="search" placeholder="当前位置：{{pagedata.pcd.street}}" ng-change="pagedata.getmerchs(true);" class="search" ng-model="pagedata.addressinfo.title"/>
				</div>
				<div class="fui-cell-remark noremark" style="margin-left:0.2rem" ng-click="pagedata.uplocation(1);">
						<i class="icon icon-ditu"></i>
						重新定位
				</div>
			</div>
	    </div>
		<div class="weui_cells_title">热门地区</div>
		<div class="weui_cells">
				<div class="row margin0">
					<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('广东省','深圳市','');pagedata.isshowarea = 0;">
									<div>深圳市</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('上海市','上海市','');pagedata.isshowarea = 0;">
									<div>上海市</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('广东省','东莞市','');pagedata.isshowarea = 0;">
									<div>东莞市</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('北京市','北京市','');pagedata.isshowarea = 0;">
									<div>北京市</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('江苏省','南京市','');pagedata.isshowarea = 0;">
									<div>南京市</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('江苏省','杭州市','');pagedata.isshowarea = 0;">
									<div>杭州市</div>
									<div class="clear"></div>
							</div>
						</div>
				</div>
			</div>
			<div ng-repeat="(value,data) in pagedata.province">
				<div class="weui_cells_title">{{value}}</div>
				<div class="weui_cells">
					<div class="row margin0">
						<div class="jy-3" ng-repeat="(city,data) in pagedata.province[value]">
								<div class="yuyue-duan" style="width:auto" ng-click="selectarea(value,city,'');pagedata.isshowarea = 0;">
										<div>{{city}}</div>
										<div class="clear"></div>
								</div>
						</div>
					</div>
				</div>
		    </div>
</div>
</div>
</div>
<script>
scope.pagedata.addressinfo={}
scope.pagedata.params.city=scope.pagedata.pcd.city?scope.pagedata.pcd.city:'';
scope.tool.get_list('jy_newpaimerch/index/getmerchs/getgoods=1&iscity=1&limit=6',true);
scope.pagedata.getmerchs=function(){
	scope.pagedata.params.city=scope.pagedata.pcd.city
	scope.tool.get_list('jy_newpaimerch/index/getmerchs/getgoods=1&iscity=1&limit=6',true,function(){
		scope.post_json('jy_newpaimerch/index/uppcd/',scope.pagedata.pcd,function(res){});
	});
	scope.pagedata.pcd.lat=scope.pagedata.params.lat;
	scope.pagedata.pcd.lng=scope.pagedata.params.lng;
}
scope.pagedata.uplocation=function(isup){
	// 百度地图API功能
	window.scope.location(function(re){
		console.log(re)
		var lat_lng = re.lat_lng;
		scope.main.lat_lng=re.lat_lng;
		scope.main.pcd=re.addressComponents;
		scope.pagedata.params.showtype=scope.pagedata.showtype;
		scope.pagedata.params.lat=lat_lng.lat;
		scope.pagedata.params.lng=lat_lng.lng;
		scope.pagedata.pcd=re.addressComponents;
		scope.pagedata.pcd.street=scope.pagedata.pcd.street_recommend?scope.pagedata.pcd.street_recommend:scope.pagedata.pcd.street;
		scope.pagedata.getmerchs();	
		if(isup){
				scope.message('定位成功');
				scope.$evalAsync();
		}	
	});
}
if(!scope.pagedata.lat_lng && !scope.main.lat_lng){
	console.log(scope.pagedata.pcd)
	scope.pagedata.uplocation();
}else{
	scope.pagedata.pcd=scope.main.pcd;
	scope.pagedata.params.lat=scope.main.lat_lng.lat;
	scope.pagedata.params.lng=scope.main.lat_lng.lng;
	scope.pagedata.getmerchs();	
}
scope.pagedata.getprovince=function(){
	scope.get('core/member.set/getprovince/',function(res){
		//console.log(res)
		scope.pagedata.province=res.province
		scope.$evalAsync();
	});
}
scope.pagedata.choose_location=function(obj,field,type){
		scope.modal_func(function(res){
			if(type && res[type]){
				var ret=res[type];
			}else{
				var ret=res;
			}
			console.log(res);
			scope.pagedata.params.lat=res.lat_lng.lat;
			scope.pagedata.params.lng=res.lat_lng.lng;
			scope.pagedata.pcd.street=res.title
			scope.pagedata.getmerchs();
			scope.$evalAsync();
		},'','core/tools.choose_location/');
}
scope.selectarea = function(province,city,district){
	scope.pagedata.pcd.province = province;
	scope.pagedata.pcd.city = city;
	scope.pagedata.pcd.district = district;
	scope.pagedata.showcity=0;
	scope.pagedata.getmerchs();
	scope.$evalAsync();
}
</script>